<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>绩效考核-下级对上级测评</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <link rel="shortcut icon" href="favicon.ico" type="image/x-icon"/>
    <link rel="stylesheet" href="static/css/font.css">
    <link rel="stylesheet" href="static/css/xadmin.css">
    <script type="text/javascript" src="static/js/jquery-3.3.1.js"></script>
    <script type="text/javascript" src="static/lib/layui/layui.js"></script>
    <script type="text/javascript" src="static/js/xadmin.js"></script>
</head>

<body class="layui-anim layui-anim-up">

<div class="x-nav">
		<span class="layui-breadcrumb"> <a>首页</a> <a>民主测评</a> <a> <cite>同级测评</cite></a>
		</span> <a class="layui-btn layui-btn-small"
                   style="line-height: 1.6em; margin-top: 3px; float: right"
                   href="javascript:location.replace(location.href);" title="刷新"> <i
        class="layui-icon" style="line-height: 30px">ဂ</i></a>
</div>
<div class="x-body" id="container">
    <div class="demoTable">
        员工号：
        <div class="layui-inline">
            <input type="number" id="e_id" name="e_id" required
                   lay-verify="number" autocomplete="off" class="layui-input" value=""/>
        </div>
        <button class="layui-btn" data-type="reload">查&nbsp;&nbsp;询</button>
    </div>
    <div style="text-align: center">
        <div span class="x-red demoTable" id='demo1'>为保证数据不丢失,请随时点击提交</div>
        <table id="demo1" class="layui-table-red" lay-filter="demo1"></table>
    </div>
    <div style="text-align: center">
        <div class="demoTable ">（*请填入1-4的数字，1：好、2：较好、3：一般、4：较差*）</div>
        <table id="demo"  class="layui-table-red "  lay-filter="demo"></table>
    </div>
    <div class="layui-inline">
        <a class="layui-btn layui-btn-danger batchUnlock" id="sbmt">
            <i class="layui-icon layui-icon-key"></i>提交</a>
    </div>
</div>
</body>
<script>
    layui.use(['laydate', 'table', 'util'], function () {
        var laydate = layui.laydate
            , table = layui.table;

        //第一个实例
        table.render({
            elem: '#demo'
            , height: 'full'
            , url: 'employeeGrand.do'
            , page: false
            , initSort: {field: 'eAccount', type: 'desc'}
            , id: 'demo'
            , cols: [[ //表头
                {field: 'eAccount', rowspan: 2, title: '工号', width: 120, align: 'center', fixed: 'left'}
                , {field: 'eName', rowspan: 2, title: '姓名', width: 80, align: 'center', fixed: 'left'}
                , {field: 'aFinish', rowspan: 2, title: '完成状态', width: 100, align: 'center', templet: '#sexTpl',fixed: 'left'}
                , {minWidth: 100, title: '德', align: 'center', colspan: 4}
                , {minWidth: 100, title: '能', align: 'center', colspan: 6}
                , {minWidth: 100, title: '勤', align: 'center', colspan: 2}
                , {minWidth: 100, title: '绩', align: 'center', colspan: 5}
                , {minWidth: 100, title: '廉', align: 'center', colspan: 2}
            ],
                [
                    {field: 'aTargetscore1', title: '政治品质', minWidth: 100, align: 'center', edit: 'number'}
                    , {field: 'aTargetscore2', title: '职业道德', minWidth: 100, align: 'center', edit: 'number'}
                    , {field: 'aTargetscore3', title: '社会公德', minWidth: 100, align: 'center', edit: 'number'}
                    , {field: 'aTargetscore4', title: '家庭美德', minWidth: 100, align: 'center', edit: 'number'}
                    , {field: 'aTargetscore5', title: '政治鉴别能力', minWidth: 120, align: 'center', edit: 'number'}
                    , {field: 'aTargetscore6', title: '沟通协调能力', minWidth: 120, align: 'center', edit: 'number'}
                    , {field: 'aTargetscore7', title: '执行能力', minWidth: 100, align: 'center', edit: 'number'}
                    , {field: 'aTargetscore8', title: '依法行政能力', minWidth: 100, align: 'center', edit: 'number'}
                    , {field: 'aTargetscore9', title: '应急处突能力', minWidth: 100, align: 'center', edit: 'number'}
                    , {field: 'aTargetscore10', title: '群众工作能力', minWidth: 100, align: 'center', edit: 'number'}
                    //, {field: 'aTargetscore11', title: '日常出勤', minWidth: 100, align: 'center', edit: 'number'}
                    , {field: 'aTargetscore12', title: '责任心', minWidth: 100, align: 'center', edit: 'number'}
                    , {field: 'aTargetscore13', title: '工作积极性', minWidth: 100, align: 'center', edit: 'number'}
                    , {field: 'aTargetscore14', title: '工作负荷', minWidth: 100, align: 'center', edit: 'number'}
                    , {field: 'aTargetscore15', title: '工作质量', minWidth: 100, align: 'center', edit: 'number'}
                    , {field: 'aTargetscore16', title: '工作时效', minWidth: 100, align: 'center', edit: 'number'}
                    , {field: 'aTargetscore17', title: '综合效益', minWidth: 100, align: 'center', edit: 'number'}
                    , {field: 'aTargetscore18', title: '工作过程', minWidth: 100, align: 'center', edit: 'number'}
                    , {field: 'aTargetscore19', title: '廉洁自律', minWidth: 100, align: 'center', edit: 'number'}
                    , {field: 'aTargetscore20', title: '勤俭节约', minWidth: 100, align: 'center', edit: 'number'}
                ]
            ]

        });

        var $ = layui.$, active = {
            reload: function () {
                var demoReload = $('#demoReload');
                //执行重载
                table.reload('demo', {
                    where: {
                        e_id: $("#e_id").val()
                    }
                });
            }
        };
        $('.demoTable .layui-btn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

        //批量提交  使用封装后的ajax
        $("#sbmt").click(function () {
            const list = table.cache['demo'];
            var len = list.length;
            var flg = "0";
            let reg = /^\d+$/g;
            for (var i = 0; i < len; i++) {
                delete list[i].LAY_TABLE_INDEX;
                list[i].aTargetscore1 = list[i].aTargetscore1.toString().replace(/\s+/g, '');
                list[i].aTargetscore2 = list[i].aTargetscore2.toString().replace(/\s+/g, '');
                list[i].aTargetscore3 = list[i].aTargetscore3.toString().replace(/\s+/g, '');
                list[i].aTargetscore4 = list[i].aTargetscore4.toString().replace(/\s+/g, '');
                list[i].aTargetscore5 = list[i].aTargetscore5.toString().replace(/\s+/g, '');
                list[i].aTargetscore6 = list[i].aTargetscore6.toString().replace(/\s+/g, '');
                list[i].aTargetscore7 = list[i].aTargetscore7.toString().replace(/\s+/g, '');
                list[i].aTargetscore8 = list[i].aTargetscore8.toString().replace(/\s+/g, '');
                list[i].aTargetscore9 = list[i].aTargetscore9.toString().replace(/\s+/g, '');
                list[i].aTargetscore10 = list[i].aTargetscore10.toString().replace(/\s+/g, '');
                list[i].aTargetscore12 = list[i].aTargetscore12.toString().replace(/\s+/g, '');
                list[i].aTargetscore13 = list[i].aTargetscore13.toString().replace(/\s+/g, '');
                list[i].aTargetscore14 = list[i].aTargetscore14.toString().replace(/\s+/g, '');
                list[i].aTargetscore15 = list[i].aTargetscore15.toString().replace(/\s+/g, '');
                list[i].aTargetscore16 = list[i].aTargetscore16.toString().replace(/\s+/g, '');
                list[i].aTargetscore17 = list[i].aTargetscore17.toString().replace(/\s+/g, '');
                list[i].aTargetscore18 = list[i].aTargetscore18.toString().replace(/\s+/g, '');
                list[i].aTargetscore19 = list[i].aTargetscore19.toString().replace(/\s+/g, '');
                list[i].aTargetscore20 = list[i].aTargetscore20.toString().replace(/\s+/g, '');
                var ttv = list[i].aTargetscore1
                if (ttv != '0' && ttv != '1' && ttv != '2' && ttv != '3' && ttv != '4') {
                    var flg = "1";
                    layer.msg('请输入正确分数,1-4的数字', {
                        time: 20000, //20s后自动关闭
                        btn: '明白了'
                    });
                    break;
                }
                if (list[i].aTargetscore2 != '0' && list[i].aTargetscore2 != '1' && list[i].aTargetscore2 != '2'
                    && list[i].aTargetscore2 != '3' && list[i].aTargetscore2 != '4') {
                    var flg = "1";
                    layer.msg('表中存在非法数据,请输入正确分数,1-4的数字', {
                        time: 20000, //20s后自动关闭
                        btn: '明白了'
                        , btnAlign: 'c' //按钮居中
                    });
                    break;
                }
                if (list[i].aTargetscore3 != '0' && list[i].aTargetscore3 != '1' && list[i].aTargetscore3 != '2'
                    && list[i].aTargetscore3 != '3' && list[i].aTargetscore3 != '4') {
                    var flg = "1";
                    layer.msg('表中存在非法数据,请输入正确分数,1-4的数字', {
                        time: 20000, //20s后自动关闭
                        btn: '明白了'
                        , btnAlign: 'c' //按钮居中
                    });
                    break;
                }
                if (list[i].aTargetscore4 != '0' && list[i].aTargetscore4 != '1' && list[i].aTargetscore4 != '2'
                    && list[i].aTargetscore4 != '3' && list[i].aTargetscore4 != '4') {
                    var flg = "1";
                    layer.msg('表中存在非法数据,请输入正确分数,1-4的数字', {
                        time: 20000, //20s后自动关闭
                        btn: '明白了'
                        , btnAlign: 'c' //按钮居中
                    });
                    break;
                }
                if (list[i].aTargetscore5 != '0' && list[i].aTargetscore5 != '1' && list[i].aTargetscore5 != '2'
                    && list[i].aTargetscore5 != '3' && list[i].aTargetscore5 != '4') {
                    var flg = "1";
                    layer.msg('表中存在非法数据,请输入正确分数,1-4的数字', {
                        time: 20000, //20s后自动关闭
                        btn: '明白了'
                        , btnAlign: 'c' //按钮居中
                    });
                    break;
                }
                if (list[i].aTargetscore6 != '0' && list[i].aTargetscore6 != '1' && list[i].aTargetscore6 != '2'
                    && list[i].aTargetscore6 != '3' && list[i].aTargetscore6 != '4') {
                    var flg = "1";
                    layer.msg('表中存在非法数据,请输入正确分数,1-4的数字', {
                        time: 20000, //20s后自动关闭
                        btn: '明白了'
                        , btnAlign: 'c' //按钮居中
                    });
                    break;
                }
                if (list[i].aTargetscore7 != '0' && list[i].aTargetscore7 != '1' && list[i].aTargetscore7 != '2'
                    && list[i].aTargetscore7 != '3' && list[i].aTargetscore7 != '4') {
                    var flg = "1";
                    layer.msg('表中存在非法数据,请输入正确分数,1-4的数字', {
                        time: 20000, //20s后自动关闭
                        btn: '明白了'
                        , btnAlign: 'c' //按钮居中
                    });
                    break;
                }
                if (list[i].aTargetscore8 != '0' && list[i].aTargetscore8 != '1' && list[i].aTargetscore8 != '2'
                    && list[i].aTargetscore8 != '3' && list[i].aTargetscore8 != '4') {
                    var flg = "1";
                    layer.msg('表中存在非法数据,请输入正确分数,1-4的数字', {
                        time: 20000, //20s后自动关闭
                        btn: '明白了'
                        , btnAlign: 'c' //按钮居中
                    });
                    break;
                }
                if (list[i].aTargetscore9 != '0' && list[i].aTargetscore9 != '1' && list[i].aTargetscore9 != '2'
                    && list[i].aTargetscore9 != '3' && list[i].aTargetscore9 != '4') {
                    var flg = "1";
                    layer.msg('表中存在非法数据,请输入正确分数,1-4的数字', {
                        time: 20000, //20s后自动关闭
                        btn: '明白了'
                        , btnAlign: 'c' //按钮居中
                    });
                    break;
                }
                if (list[i].aTargetscore10 != '0' && list[i].aTargetscore10 != '1' && list[i].aTargetscore10 != '2'
                    && list[i].aTargetscore10 != '3' && list[i].aTargetscore10 != '4') {
                    var flg = "1";
                    layer.msg('表中存在非法数据,请输入正确分数,1-4的数字', {
                        time: 20000, //20s后自动关闭
                        btn: '明白了'
                        , btnAlign: 'c' //按钮居中
                    });
                    break;
                }
                if (list[i].aTargetscore11 != '0' && list[i].aTargetscore11 != '1' && list[i].aTargetscore11 != '2'
                    && list[i].aTargetscore11 != '3' && list[i].aTargetscore11 != '4') {
                    var flg = "1";
                    layer.msg('表中存在非法数据,请输入正确分数,1-4的数字', {
                        time: 20000, //20s后自动关闭
                        btn: '明白了'
                        , btnAlign: 'c' //按钮居中
                    });
                    break;
                }
                if (list[i].aTargetscore12 != '0' && list[i].aTargetscore12 != '1' && list[i].aTargetscore12 != '2'
                    && list[i].aTargetscore12 != '3' && list[i].aTargetscore12 != '4') {
                    var flg = "1";
                    layer.msg('表中存在非法数据,请输入正确分数,1-4的数字', {
                        time: 20000, //20s后自动关闭
                        btn: '明白了'
                        , btnAlign: 'c' //按钮居中
                    });
                    break;
                }
                if (list[i].aTargetscore13 != '0' && list[i].aTargetscore13 != '1' && list[i].aTargetscore13 != '2'
                    && list[i].aTargetscore13 != '3' && list[i].aTargetscore13 != '4') {
                    var flg = "1";
                    layer.msg('表中存在非法数据,请输入正确分数,1-4的数字', {
                        time: 20000, //20s后自动关闭
                        btn: '明白了'
                        , btnAlign: 'c' //按钮居中
                    });
                    break;
                }
                if (list[i].aTargetscore14 != '0' && list[i].aTargetscore14 != '1' && list[i].aTargetscore14 != '2'
                    && list[i].aTargetscore14 != '3' && list[i].aTargetscore14 != '4') {
                    var flg = "1";
                    layer.msg('表中存在非法数据,请输入正确分数,1-4的数字', {
                        time: 20000, //20s后自动关闭
                        btn: '明白了'
                        , btnAlign: 'c' //按钮居中
                    });
                    break;
                }
                if (list[i].aTargetscore15 != '0' && list[i].aTargetscore15 != '1' && list[i].aTargetscore15 != '2'
                    && list[i].aTargetscore15 != '3' && list[i].aTargetscore15 != '4') {
                    var flg = "1";
                    layer.msg('表中存在非法数据,请输入正确分数,1-4的数字', {
                        time: 20000, //20s后自动关闭
                        btn: '明白了'
                        , btnAlign: 'c' //按钮居中
                    });
                    break;
                }
                if (list[i].aTargetscore16 != '0' && list[i].aTargetscore16 != '1' && list[i].aTargetscore16 != '2'
                    && list[i].aTargetscore16 != '3' && list[i].aTargetscore16 != '4') {
                    var flg = "1";
                    layer.msg('表中存在非法数据,请输入正确分数,1-4的数字', {
                        time: 20000, //20s后自动关闭
                        btn: '明白了'
                        , btnAlign: 'c' //按钮居中
                    });
                    break;
                }
                if (list[i].aTargetscore17 != '0' && list[i].aTargetscore17 != '1' && list[i].aTargetscore17 != '2'
                    && list[i].aTargetscore17 != '3' && list[i].aTargetscore17 != '4') {
                    var flg = "1";
                    layer.msg('表中存在非法数据,请输入正确分数,1-4的数字', {
                        time: 20000, //20s后自动关闭
                        btn: '明白了'
                        , btnAlign: 'c' //按钮居中
                    });
                    break;
                }
                if (list[i].aTargetscore18 != '0' && list[i].aTargetscore18 != '1' && list[i].aTargetscore18 != '2'
                    && list[i].aTargetscore18 != '3' && list[i].aTargetscore18 != '4') {
                    var flg = "1";
                    layer.msg('表中存在非法数据,请输入正确分数,1-4的数字', {
                        time: 20000, //20s后自动关闭
                        btn: '明白了'
                        , btnAlign: 'c' //按钮居中
                    });
                    break;
                }
                if (list[i].aTargetscore19 != '0' && list[i].aTargetscore19 != '1' && list[i].aTargetscore19 != '2'
                    && list[i].aTargetscore19 != '3' && list[i].aTargetscore19 != '4') {
                    var flg = "1";
                    layer.msg('表中存在非法数据,请输入正确分数,1-4的数字', {
                        time: 20000, //20s后自动关闭
                        btn: '明白了'
                        , btnAlign: 'c' //按钮居中
                    });
                    break;
                }
                if (list[i].aTargetscore20 != '0' && list[i].aTargetscore20 != '1' && list[i].aTargetscore20 != '2'
                    && list[i].aTargetscore20 != '3' && list[i].aTargetscore20 != '4') {
                    var flg = "1";
                    layer.msg('表中存在非法数据,请输入正确分数,1-4的数字', {
                        time: 20000, //20s后自动关闭
                        btn: '明白了'
                        , btnAlign: 'c' //按钮居中
                    });
                    break;
                }
            }
            if (flg == '0') {
                $.ajax({
                    type: 'post',
                    url: 'updateGrand.do',
                    data: "list=" + JSON.stringify(list),
                    dataType: 'json',
                    success: function (result) {
                        if (result.code == 0) {
                            layer.msg(result.msg);
                            table.reload('demo', {
                                where: {
                                    e_id: $("#e_id").val()
                                }
                            });
                        } else {
                            layer.msg(result.msg);
                        }
                    }
                });
            }
        });

        //监听单元格编辑
        table.on('edit(demo)', function (obj) {
            var ttv = obj.value //得到修改后的值
                , data = obj.data //得到所在行所有键值
            ttv = ttv.replace(/\s+/g, '');
            if (ttv != '1' && ttv != '2' && ttv != '3' && ttv != '4') {
                layer.msg('请输入正确分数,1-4的数字', {
                    time: 20000 //20s后自动关闭
                    , btn: '明白了'
                    , btnAlign: 'c' //按钮居中
                });

                /**添加禁用按钮样式
                 $("#sbmt").addClass("layui-btn-disabled");
                 //真正禁用按钮的语句
                 $("#sbmt").attr("disabled", true);
                 **/
            }
            /**
             else {
				//去除禁用样式
				$("#sbmt").removeClass("layui-btn-disabled");
				//解除禁用的语句
				$("#sbmt").attr("disabled", false);
			}
             **/
        });

    });
</script>
<script type="text/html" id="sexTpl">
    {{#  if(d.aFinish === "未完成"){ }}
    <span class="layui-badge layui-bg-red">未完成</span>
    {{#  } else { }}
    <span class="layui-badge layui-bg-green">已完成</span>
    {{#  } }}
</script>
</html>
